/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Gui;

import java.net.Socket;
import javax.swing.ImageIcon;

import Params.ChatMessage;
import Params.ServerSocketItem;

/**
 *
 * @author Administrator
 */
public class frmCaptureClient extends javax.swing.JInternalFrame {

    Socket _sockhientai = null;

    /**
     * Creates new form frmCaptureClient
     */
    public frmCaptureClient() {
        initComponents();
    }

    frmCaptureClient(String strPort, Socket temp) throws InterruptedException {
        initComponents();

        //initServer(strPort);
        _sockhientai = temp;
        int temp1 = (temp.getPort());
        this.title = "CAPTURE SCREEN - CLIENT " + temp1 + "";
        capturescreen();
    }

    private void capturescreen() throws InterruptedException {

        for (int i = 0; i < MainSever.listConnection.size(); i++) {
            ServerSocketItem temp = (ServerSocketItem) MainSever.listConnection.elementAt(i);
            Socket _tempsock = temp.getSOCK();
            if (_tempsock.getPort() == _sockhientai.getPort()) {

                temp.getConnectionCapture().bufferedWriter.println("Thong Bao Chup Hinh");
                temp.getConnectionCapture().bufferedWriter.flush();
                break;
            }

        }
    }

    void onRead(ChatMessage message) {
        ImageIcon icon = (ImageIcon) message.getImg();
        jLabel1.setIcon(icon);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        jLabel1 = new javax.swing.JLabel();

        setClosable(true);
        setMaximizable(true);
        setResizable(true);
        setTitle("Capture Client");

        jLabel1.setToolTipText("");
        jLabel1.setAutoscrolls(true);
        jScrollPane2.setViewportView(jLabel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 590, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 452, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration//GEN-END:variables
}
